#!/bin/bash  
# description: Tomcat Start Stop Restart  
# processname: tomcat  
# chkconfig: 234 20 80  
TOMCAT_HOME=/usr/local/tomcat-flow1
TOMCAT_KEY=tomcat-flow1
source /etc/profile
case $1 in
start)
/bin/su  root  $TOMCAT_HOME/bin/startup.sh
;;
stop)
pid=`ps -ef|grep "java"|grep "$TOMCAT_KEY"|grep -v "grep"|awk '{print $2}' |xargs`
if [ -z $pid ];then
echo "tomcat(${TOMCAT_KEY}) is not running"
else
kill -9 $pid
fi
;;
restart)
pid=`ps -ef|grep "java"|grep "$TOMCAT_KEY"|grep -v "grep"|awk '{print $2}' |xargs`
if [ -z $pid ];then
echo "tomcat(${TOMCAT_KEY}) is not running"
else
kill -9 $pid
fi
$TOMCAT_HOME/bin/startup.sh
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0